package com.chankudo;

import com.chankudo.demo2.Demo2FactoryBean;
import com.chankudo.demo2.Demo2Product;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class demoApp2 {
    public static void main(String[] args) {
        String xmlPath = "demo2.xml";
        ApplicationContext context = new ClassPathXmlApplicationContext(xmlPath);

        // //静态工厂类生产的bean scope为prototype
        // Demo2Product product1 = (Demo2Product)context.getBean("product1");
        // System.out.println(product1);
        // Demo2Product product2 = (Demo2Product)context.getBean("product2");
        // System.out.println(product2);
        // Demo2Product product3 = (Demo2Product)context.getBean("product3");
        // System.out.println(product3+" id:"+product3.getProductId());

        // //静态工厂类生产的bean scope为singleton
        // Demo2Product sproduct1 = (Demo2Product)context.getBean("sproduct1");
        // System.out.println(sproduct1+" id:"+sproduct1.getProductId());
        // Demo2Product sproduct2 = (Demo2Product)context.getBean("sproduct2");
        // System.out.println(sproduct2+" id:"+sproduct1.getProductId());

        // //非静态工厂类生产的bean scope为prototype
        // Demo2Product product4 = (Demo2Product)context.getBean("product4");
        // System.out.println(product4);
        // Demo2Product product5 = (Demo2Product)context.getBean("product5");
        // System.out.println(product5+" id:"+product5.getProductId());
        
        // //非静态工厂类生产的bean scope为singleton
        // Demo2Product sproduct3 = (Demo2Product)context.getBean("sproduct3");
        // System.out.println(sproduct3+" id:"+sproduct3.getProductId());
        // Demo2Product sproduct4 = (Demo2Product)context.getBean("sproduct4");
        // System.out.println(sproduct4+" id:"+sproduct4.getProductId());

        // //实现FactoryBean接口的工厂类生产的bean
        // Demo2Product fProduct = (Demo2Product)context.getBean("fproduct");
        // System.out.println(fProduct.getClass());
        // //访问工厂类本身
        // Demo2FactoryBean factoryBean = (Demo2FactoryBean)context.getBean("&fproduct");
        // System.out.println(factoryBean.getClass());

    }
}
